function formatDate() {
    let date = new Date();//获得时间 当前系统时间
    console.log(date);

    //获得年
    let year = date.getFullYear();
    console.log(`year=${year}`);
    //月 输出的是月份的下标
    let month = date.getMonth();
    console.log(`year=${month}`);
    //月中的天
    let dayOfMonth = date.getDate();
    console.log(`year=${dayOfMonth}`);

    //周中的天
    let dayOfWeek = date.getDay();
    console.log(`dayOfWeek=${dayOfWeek}`);
    let hour = date.getHours();
    console.log(`hour=${hour}`);
    let minute = date.getMinutes();
    console.log(`minute=${minute}`);
    let second = date.getSeconds();
    console.log(`second=${second}`);
    let str = `${year}-${month + 1}-${dayOfMonth}-${hour}:${minute}:${second}&nbsp;周${dayOfWeek}`;
    return str;
}

//页面加载结束执行的函数，只能写一次
onload = function () {
    //定时函数 1000=1s
    setInterval(function () {
        //向app元素中写内容
        app.innerHTML = '今天是' + formatDate()
    }, 1)
}


